#pragma once

#include "SPEmitter.h"

namespace SP
{
	class DLL_EXPORT SPEmitterAnimTrail : public SPEmitter
	{
	public:
		struct VERTEX
		{
			XMFLOAT3 vCtrlPos;
			XMFLOAT3 vPrePos;
			XMFLOAT3 vPostPos;
		};

		SPEmitterAnimTrail();
		SPEmitterAnimTrail( SPEmitterAnimTrail* archetpye );
		virtual ~SPEmitterAnimTrail();

		void Create(  SPEmitterAnimTrail* archetype );

		virtual void Initialize();
		virtual void Render();
		virtual void Advance( float fElapsedTime );
		virtual void ClearModule();
		virtual void CreateFileBuffer( SPFileBuffer* );
		virtual void CreateFromFileBuffer( BYTE* );
		virtual bool SetSPModule( SPModule* pModule );
		
		HRESULT Create( UINT nNumControlLine );
		void SetTessellationAmount( UINT nAmount ){ m_nTessellationAmount = nAmount; }

		void SetHead( const XMFLOAT3& vLeftHead, const XMFLOAT3& vRightHead )
		{
			m_vLeftHead = vLeftHead;
			m_vRightHead = vRightHead;
		}

		//void AbsLocation( bool bAbs ){ m_bAbsLocation = bAbs; }
		void AbsHead( bool bAbs ){ m_bAbsHead = bAbs; }

		void AnimTrailDuration( FLOAT fDuration ){ m_fAnimTrailDuration = fDuration; } 

		HRESULT CreateTextureFromFile( const wchar_t* file );
	protected:
		FLOAT m_fNewControlLineRamain;
		FLOAT m_fAnimTrailDuration;
		UINT m_nTessellationAmount;
		UINT m_nNumControlLine;
		
		//bool m_bAbsLocation;
		bool m_bAbsHead;

		VERTEX* m_pVertices;
		VERTEX* m_pVerticesCopy;
		ID3D11Buffer* m_pVertexBuffer;

		XMFLOAT3 m_vLeftHead;
		XMFLOAT3 m_vRightHead;

		VERTEX m_vLeftEnd;
		VERTEX m_vRightEnd;

		// Texture
		ID3D11Resource* m_pTex;
		ID3D11ShaderResourceView* m_pTexSRV;

		void SetZero();
		void Release();

		friend class SPEmitterAnimTrailRenderer;
	};


}


